const { contextBridge, ipcRenderer } = require('electron/renderer')
const fs = require('fs')

// 主题色
contextBridge.exposeInMainWorld('darkMode', {
  toggle: () => ipcRenderer.invoke('dark-mode:toggle'),
  system: () => ipcRenderer.invoke('dark-mode:system')
})

// 读取文件 + 访问process对象
window.addEventListener("DOMContentLoaded",()=>{
    // 读取process对象对应平台版本
    for(const item of ["chrome","node","electron"]){
        console.log(`${item}-version`,process.versions[item])
    }
    let namesList = document.querySelector("#namesList")

    // 读取文件系统
    fs.readFile("./files/namesList.txt",(err,data)=>{
        namesList.innerHTML = data
    })
})
